home *** CD-ROM | disk | FTP | other *** search
/ Amiga Magazin: Amiga-CD 1996 September & October / Amiga-CD 1996 #9-10.iso / demos / storm-c / stormc / include / dos / dos.h < prev    next >
C/C++ Source or Header  |  1994-03-15  |  11KB  |  282 lines

  1. #ifndef DOS_DOS_H
  2. #define DOS_DOS_H
  3. /*
  4. **    $VER: dos.h 36.27 (5.4.92)
  5. **    Includes Release 40.15
  6. **
  7. **    Standard C header for AmigaDOS
  8. **
  9. **    (C) Copyright 1985-1993 Commodore-Amiga, Inc.
  10. **        All Rights Reserved
  11. */
  12.  
  13. #ifndef EXEC_TYPES_H
  14. #include "exec/types.h"
  15. #endif
  16.  
  17.  
  18. #define     DOSNAME  "dos.library"
  19.  
  20. /* Predefined Amiga DOS global constants */
  21.  
  22. #define DOSTRUE (-1L)
  23. #define DOSFALSE (0L)
  24.  
  25. /* Mode parameter to Open() */
  26. #define MODE_OLDFILE         1005   /* Open existing file read/write
  27.                      * positioned at beginning of file. */
  28. #define MODE_NEWFILE         1006   /* Open freshly created file (delete
  29.                      * old file) read/write, exclusive lock. */
  30. #define MODE_READWRITE         1004   /* Open old file w/shared lock,
  31.                      * creates file if doesn't exist. */
  32.  
  33. /* Relative position to Seek() */
  34. #define OFFSET_BEGINNING    -1        /* relative to Begining Of File */
  35. #define OFFSET_CURRENT         0        /* relative to Current file position */
  36. #define OFFSET_END         1        /* relative to End Of File      */
  37.  
  38. #define OFFSET_BEGINING        OFFSET_BEGINNING  /* ancient compatibility */
  39.  
  40. #define BITSPERBYTE         8
  41. #define BYTESPERLONG         4
  42. #define BITSPERLONG         32
  43. #define MAXINT             0x7FFFFFFF
  44. #define MININT             0x80000000
  45.  
  46. /* Passed as type to Lock() */
  47. #define SHARED_LOCK         -2        /* File is readable by others */
  48. #define ACCESS_READ         -2        /* Synonym */
  49. #define EXCLUSIVE_LOCK         -1        /* No other access allowed      */
  50. #define ACCESS_WRITE         -1        /* Synonym */
  51.  
  52. struct DateStamp {
  53.    LONG     ds_Days;          /* Number of days since Jan. 1, 1978 */
  54.    LONG     ds_Minute;          /* Number of minutes past midnight */
  55.    LONG     ds_Tick;          /* Number of ticks past minute */
  56. }; /* DateStamp */
  57.  
  58. #define TICKS_PER_SECOND      50   /* Number of ticks in one second */
  59.  
  60. /* Returned by Examine() and ExNext(), must be on a 4 byte boundary */
  61. struct FileInfoBlock {
  62.    LONG      fib_DiskKey;
  63.    LONG      fib_DirEntryType;  /* Type of Directory. If < 0, then a plain file.
  64.                   * If > 0 a directory */
  65.    char      fib_FileName[108]; /* Null terminated. Max 30 chars used for now */
  66.    LONG      fib_Protection;    /* bit mask of protection, rwxd are 3-0.       */
  67.    LONG      fib_EntryType;
  68.    LONG      fib_Size;         /* Number of bytes in file */
  69.    LONG      fib_NumBlocks;     /* Number of blocks in file */
  70.    struct DateStamp fib_Date;/* Date file last changed */
  71.    char      fib_Comment[80];  /* Null terminated comment associated with file */
  72.  
  73.    /* Note: the following fields are not supported by all filesystems.    */
  74.    /* They should be initialized to 0 sending an ACTION_EXAMINE packet.    */
  75.    /* When Examine() is called, these are set to 0 for you.        */
  76.    /* AllocDosObject() also initializes them to 0.            */
  77.    UWORD  fib_OwnerUID;        /* owner's UID */
  78.    UWORD  fib_OwnerGID;        /* owner's GID */
  79.  
  80.    char      fib_Reserved[32];
  81. }; /* FileInfoBlock */
  82.  
  83. /* FIB stands for FileInfoBlock */
  84.  
  85. /* FIBB are bit definitions, FIBF are field definitions */
  86. /* Regular RWED bits are 0 == allowed. */
  87. /* NOTE: GRP and OTR RWED permissions are 0 == not allowed! */
  88. /* Group and Other permissions are not directly handled by the filesystem */
  89. #define FIBB_OTR_READ       15    /* Other: file is readable */
  90. #define FIBB_OTR_WRITE       14    /* Other: file is writable */
  91. #define FIBB_OTR_EXECUTE   13    /* Other: file is executable */
  92. #define FIBB_OTR_DELETE    12    /* Other: prevent file from being deleted */
  93. #define FIBB_GRP_READ       11    /* Group: file is readable */
  94. #define FIBB_GRP_WRITE       10    /* Group: file is writable */
  95. #define FIBB_GRP_EXECUTE   9    /* Group: file is executable */
  96. #define FIBB_GRP_DELETE    8    /* Group: prevent file from being deleted */
  97.  
  98. #define FIBB_SCRIPT    6    /* program is a script (execute) file */
  99. #define FIBB_PURE      5    /* program is reentrant and rexecutable */
  100. #define FIBB_ARCHIVE   4    /* cleared whenever file is changed */
  101. #define FIBB_READ      3    /* ignored by old filesystem */
  102. #define FIBB_WRITE     2    /* ignored by old filesystem */
  103. #define FIBB_EXECUTE   1    /* ignored by system, used by Shell */
  104. #define FIBB_DELETE    0    /* prevent file from being deleted */
  105.  
  106. #define FIBF_OTR_READ       (1<<FIBB_OTR_READ)
  107. #define FIBF_OTR_WRITE       (1<<FIBB_OTR_WRITE)
  108. #define FIBF_OTR_EXECUTE   (1<<FIBB_OTR_EXECUTE)
  109. #define FIBF_OTR_DELETE    (1<<FIBB_OTR_DELETE)
  110. #define FIBF_GRP_READ       (1<<FIBB_GRP_READ)
  111. #define FIBF_GRP_WRITE       (1<<FIBB_GRP_WRITE)
  112. #define FIBF_GRP_EXECUTE   (1<<FIBB_GRP_EXECUTE)
  113. #define FIBF_GRP_DELETE    (1<<FIBB_GRP_DELETE)
  114.  
  115. #define FIBF_SCRIPT    (1<<FIBB_SCRIPT)
  116. #define FIBF_PURE      (1<<FIBB_PURE)
  117. #define FIBF_ARCHIVE   (1<<FIBB_ARCHIVE)
  118. #define FIBF_READ      (1<<FIBB_READ)
  119. #define FIBF_WRITE     (1<<FIBB_WRITE)
  120. #define FIBF_EXECUTE   (1<<FIBB_EXECUTE)
  121. #define FIBF_DELETE    (1<<FIBB_DELETE)
  122.  
  123. /* Standard maximum length for an error string from fault.  However, most */
  124. /* error strings should be kept under 60 characters if possible.  Don't   */
  125. /* forget space for the header you pass in. */
  126. #define FAULT_MAX    82
  127.  
  128. /* All BCPL data must be long word aligned.  BCPL pointers are the long word
  129.  *  address (i.e byte address divided by 4 (>>2)) */
  130. typedef long  BPTR;            /* Long word pointer */
  131. typedef long  BSTR;            /* Long word pointer to BCPL string     */
  132.  
  133. /* Convert BPTR to typical C pointer */
  134. #ifdef OBSOLETE_LIBRARIES_DOS_H
  135. #define BADDR( bptr )    (((ULONG)bptr) << 2)
  136. #else
  137. /* This one has no problems with CASTing */
  138. #define BADDR(x)    ((APTR)((ULONG)(x) << 2))
  139. #endif
  140. /* Convert address into a BPTR */
  141. #define MKBADDR(x)    (((LONG)(x)) >> 2)
  142.  
  143. /* BCPL strings have a length in the first byte and then the characters.
  144.  * For example:     s[0]=3 s[1]=S s[2]=Y s[3]=S                 */
  145.  
  146. /* returned by Info(), must be on a 4 byte boundary */
  147. struct InfoData {
  148.    LONG      id_NumSoftErrors;    /* number of soft errors on disk */
  149.    LONG      id_UnitNumber;    /* Which unit disk is (was) mounted on */
  150.    LONG      id_DiskState;        /* See defines below */
  151.    LONG      id_NumBlocks;        /* Number of blocks on disk */
  152.    LONG      id_NumBlocksUsed;    /* Number of block in use */
  153.    LONG      id_BytesPerBlock;
  154.    LONG      id_DiskType;        /* Disk Type code */
  155.    BPTR      id_VolumeNode;    /* BCPL pointer to volume node */
  156.    LONG      id_InUse;        /* Flag, zero if not in use */
  157. }; /* InfoData */
  158.  
  159. /* ID stands for InfoData */
  160.     /* Disk states */
  161. #define ID_WRITE_PROTECTED 80     /* Disk is write protected */
  162. #define ID_VALIDATING       81     /* Disk is currently being validated */
  163. #define ID_VALIDATED       82     /* Disk is consistent and writeable */
  164.  
  165.     /* Disk types */
  166. /* ID_INTER_* use international case comparison routines for hashing */
  167. /* Any other new filesystems should also, if possible. */
  168. #define ID_NO_DISK_PRESENT    (-1)
  169. #define ID_UNREADABLE_DISK    (0x42414400L)    /* 'BAD\0' */
  170. #define ID_DOS_DISK        (0x444F5300L)    /* 'DOS\0' */
  171. #define ID_FFS_DISK        (0x444F5301L)    /* 'DOS\1' */
  172. #define ID_INTER_DOS_DISK    (0x444F5302L)    /* 'DOS\2' */
  173. #define ID_INTER_FFS_DISK    (0x444F5303L)    /* 'DOS\3' */
  174. #define ID_FASTDIR_DOS_DISK    (0x444F5304L)    /* 'DOS\4' */
  175. #define ID_FASTDIR_FFS_DISK    (0x444F5305L)    /* 'DOS\5' */
  176. #define ID_NOT_REALLY_DOS    (0x4E444F53L)    /* 'NDOS'  */
  177. #define ID_KICKSTART_DISK    (0x4B49434BL)    /* 'KICK'  */
  178. #define ID_MSDOS_DISK        (0x4d534400L)    /* 'MSD\0' */
  179.  
  180. /* Errors from IoErr(), etc. */
  181. #define ERROR_NO_FREE_STORE          103
  182. #define ERROR_TASK_TABLE_FULL          105
  183. #define ERROR_BAD_TEMPLATE          114
  184. #define ERROR_BAD_NUMBER          115
  185. #define ERROR_REQUIRED_ARG_MISSING      116
  186. #define ERROR_KEY_NEEDS_ARG          117
  187. #define ERROR_TOO_MANY_ARGS          118
  188. #define ERROR_UNMATCHED_QUOTES          119
  189. #define ERROR_LINE_TOO_LONG          120
  190. #define ERROR_FILE_NOT_OBJECT          121
  191. #define ERROR_INVALID_RESIDENT_LIBRARY      122
  192. #define ERROR_NO_DEFAULT_DIR          201
  193. #define ERROR_OBJECT_IN_USE          202
  194. #define ERROR_OBJECT_EXISTS          203
  195. #define ERROR_DIR_NOT_FOUND          204
  196. #define ERROR_OBJECT_NOT_FOUND          205
  197. #define ERROR_BAD_STREAM_NAME          206
  198. #define ERROR_OBJECT_TOO_LARGE          207
  199. #define ERROR_ACTION_NOT_KNOWN          209
  200. #define ERROR_INVALID_COMPONENT_NAME      210
  201. #define ERROR_INVALID_LOCK          211
  202. #define ERROR_OBJECT_WRONG_TYPE          212
  203. #define ERROR_DISK_NOT_VALIDATED      213
  204. #define ERROR_DISK_WRITE_PROTECTED      214
  205. #define ERROR_RENAME_ACROSS_DEVICES      215
  206. #define ERROR_DIRECTORY_NOT_EMPTY      216
  207. #define ERROR_TOO_MANY_LEVELS          217
  208. #define ERROR_DEVICE_NOT_MOUNTED      218
  209. #define ERROR_SEEK_ERROR          219
  210. #define ERROR_COMMENT_TOO_BIG          220
  211. #define ERROR_DISK_FULL              221
  212. #define ERROR_DELETE_PROTECTED          222
  213. #define ERROR_WRITE_PROTECTED          223
  214. #define ERROR_READ_PROTECTED          224
  215. #define ERROR_NOT_A_DOS_DISK          225
  216. #define ERROR_NO_DISK              226
  217. #define ERROR_NO_MORE_ENTRIES          232
  218. /* added for 1.4 */
  219. #define ERROR_IS_SOFT_LINK          233
  220. #define ERROR_OBJECT_LINKED          234
  221. #define ERROR_BAD_HUNK              235
  222. #define ERROR_NOT_IMPLEMENTED          236
  223. #define ERROR_RECORD_NOT_LOCKED          240
  224. #define ERROR_LOCK_COLLISION          241
  225. #define ERROR_LOCK_TIMEOUT          242
  226. #define ERROR_UNLOCK_ERROR          243
  227.  
  228. /* error codes 303-305 are defined in dosasl.h */
  229.  
  230. /* These are the return codes used by convention by AmigaDOS commands */
  231. /* See FAILAT and IF for relvance to EXECUTE files              */
  232. #define RETURN_OK                0  /* No problems, success */
  233. #define RETURN_WARN                5  /* A warning only */
  234. #define RETURN_ERROR               10  /* Something wrong */
  235. #define RETURN_FAIL               20  /* Complete or severe failure*/
  236.  
  237. /* Bit numbers that signal you that a user has issued a break */
  238. #define SIGBREAKB_CTRL_C   12
  239. #define SIGBREAKB_CTRL_D   13
  240. #define SIGBREAKB_CTRL_E   14
  241. #define SIGBREAKB_CTRL_F   15
  242.  
  243. /* Bit fields that signal you that a user has issued a break */
  244. /* for example:     if (SetSignal(0,0) & SIGBREAKF_CTRL_C) cleanup_and_exit(); */
  245. #define SIGBREAKF_CTRL_C   (1<<SIGBREAKB_CTRL_C)
  246. #define SIGBREAKF_CTRL_D   (1<<SIGBREAKB_CTRL_D)
  247. #define SIGBREAKF_CTRL_E   (1<<SIGBREAKB_CTRL_E)
  248. #define SIGBREAKF_CTRL_F   ((long)1<<SIGBREAKB_CTRL_F)
  249.  
  250. /* Values returned by SameLock() */
  251. #define LOCK_DIFFERENT        -1
  252. #define LOCK_SAME        0
  253. #define LOCK_SAME_VOLUME    1    /* locks are on same volume */
  254. #define LOCK_SAME_HANDLER    LOCK_SAME_VOLUME
  255. /* LOCK_SAME_HANDLER was a misleading name, def kept for src compatibility */
  256.  
  257. /* types for ChangeMode() */
  258. #define CHANGE_LOCK    0
  259. #define CHANGE_FH    1
  260.  
  261. /* Values for MakeLink() */
  262. #define LINK_HARD    0
  263. #define LINK_SOFT    1    /* softlinks are not fully supported yet */
  264.  
  265. /* values returned by ReadItem */
  266. #define    ITEM_EQUAL    -2        /* "=" Symbol */
  267. #define ITEM_ERROR    -1        /* error */
  268. #define ITEM_NOTHING    0        /* *N, ;, endstreamch */
  269. #define ITEM_UNQUOTED    1        /* unquoted item */
  270. #define ITEM_QUOTED    2        /* quoted item */
  271.  
  272. /* types for AllocDosObject/FreeDosObject */
  273. #define DOS_FILEHANDLE        0    /* few people should use this */
  274. #define DOS_EXALLCONTROL    1    /* Must be used to allocate this! */
  275. #define    DOS_FIB            2    /* useful */
  276. #define DOS_STDPKT        3    /* for doing packet-level I/O */
  277. #define DOS_CLI            4    /* for shell-writers, etc */
  278. #define DOS_RDARGS        5    /* for ReadArgs if you pass it in */
  279.  
  280. #endif    /* DOS_DOS_H */
  281.  
  282.